import cv2
import numpy as np

# 读入图像
image = cv2.imread("images/color_recognition/polygon.jpg")

# 显示图像
cv2.imshow('polygon', image)

# 设置hsv范围参数
lower = np.array([0, 0, 147], dtype=np.uint8)
upper = np.array([45, 43, 255], dtype=np.uint8)

# 生成二值图并显示
mask = cv2.inRange(image, lower, upper)
cv2.imshow("hsv", mask)

cv2.waitKey(0)
